<input type="text">
<div class="loading"></div>
<ul></ul>
<script src="./axios封装.js"></script>
<script>
    var iptObj=document.querySelector('input')
    iptObj.oninput=function(){
        document.querySelector('div.loading').innerHTML = `<img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fstatic.iamxk.com%2Fwp-content%2Fuploads%2F2018%2F01%2F5687000234ee8da57311.gif&refer=http%3A%2F%2Fstatic.iamxk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1654674271&t=4f5bec847ef11133e824b1f2a07bec73" />`
        get(
            'https://www.baidu.com/sugrec',
            {
            prod:'pc',
            wd: this.value
            },
            'json'
        )
        .then(res=>{
            document.querySelector('ul').innerText = ''
            if(!res.g) return
            res.g.forEach((item,i)=>{
                let liObj = document.createElement('li')
            liObj.innerText = item.q 
            document.querySelector('ul').appendChild(liObj)
            })
        })
        .catch(err=>{
            console.log('瑕疵:',err);
        })
        .finally(()=>{
            document.querySelector('div.loading').innerText = ''
        })
    }
</script>